<template>
<!--  #334157-->
  <el-menu class="el-menu-demo" mode="horizontal" background-color="#ffff" text-color="#black" active-text-color="#black">
    <el-button class="buttonImg">
      <div :class="collapsed?'el-icon-s-fold showimg':'el-icon-s-unfold showimg'" @click="toggle(collapsed)"></div>
    </el-button>
    <el-submenu index="2" class="submenu">
      <template slot="title">
        <i class="el-icon-user submenu-text"></i>用户
      </template>
      <el-menu-item index="2-1">设置</el-menu-item>
      <el-menu-item @click="content()" index="2-2">前台</el-menu-item>
      <el-menu-item @click="exit()" index="2-3">退出</el-menu-item>
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  name: "navcon",
  data() {
    return{
      collapsed: true,
    }
  },
  methods: {
    toggle(showtype){
      this.collapsed = !showtype;
      this.$root.Bus.$emit('toggle', this.collapsed);
    },
    content(){
      this.$router.push({ path: '/home' });
    },
    exit() {
      this.$confirm('退出登录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            setTimeout(() => {
              window.sessionStorage.clear();
              this.$router.push({ path: '/login' })
              this.$message({
                type: 'success',
                message: '已退出登录!'
              })
            }, 1000)
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消'
            })
          })
    }
  }
}
</script>

<style lang="less" scoped>
.el-menu-demo{
  .buttonImg {
    height: 60px;
    background-color: transparent;
    border: none;
    margin: 0;
    padding: 0;
    .showimg {
      font-size: 38px;
      //background-color: #125716;
      color: #000509;//ffffff
    }
  }
  .submenu {
    //color: #000509 !important;// ffffff
    float: right;
    .el-submenu__title{
      color: #000509;
      .submenu-text{
        color: #000509;// ffffff
        font-size: 25px;
      }
    }

  }
}
</style>
